// Error correction: distance-three 5-qubit code, from the paper "Benchmarking gate-based quantum computers" by K. Michielsen et al.

OPENQASM 2.0;
include "qelib1.inc";

qreg q[5];
creg c[5];

h q[0];
h q[1];
id q[2];
h q[3];
h q[4];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
cx q[4],q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
sdg q[4];
cx q[4],q[2];
h q[2];
cx q[4],q[2];
h q[2];
cx q[0],q[2];
h q[0];
h q[2];
cx q[0],q[2];
h q[0];
h q[2];
cx q[0],q[2];
cx q[3],q[2];
cx q[0],q[2];
h q[0];
h q[2];
cx q[0],q[2];
h q[0];
h q[2];
cx q[0],q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
cx q[3],q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
h q[1];
h q[2];
cx q[1],q[2];
cx q[3],q[2];
cx q[0],q[2];
h q[3];
h q[4];
cx q[3],q[2];
h q[2];
h q[3];
cx q[3],q[2];
h q[2];
h q[3];
cx q[3],q[2];
cx q[0],q[2];
cx q[3],q[2];
h q[2];
h q[3];
cx q[3],q[2];
h q[2];
h q[3];
cx q[3],q[2];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
cx q[0],q[2];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
cx q[1],q[2] ;
h q[2];
cx q[1],q[2];
h q[1];
cx q[4],q[2];
cx q[0],q[1];
h q[2];
h q[4];
h q[1];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
cx q[1],q[2];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
h q[2];
h q[4];
cx q[4],q[2];
sdg q[1];
h q[2];
h q[3];
h q[4];

measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
